// API 响应类型定义
export interface ApiResponse<T = any> {
  records: any;
  total: any;
  filter(arg0: (role: any) => boolean): Role[] | { id: number; name: string; code: string; status: string; createTime?: string | undefined; updateTime?: string | undefined; }[];
  code: number
  message: string
  data: T
}

// 添加一个工具函数判断响应是否成功
export function isSuccess(response: ApiResponse<any>): boolean {
  return response.code === 200
}

// 分页请求参数
export interface PageParams {
  pageNum: number
  pageSize: number
}

// 分页响应数据（适配 MyBatis Plus）
export interface PageResult<T> {
  records: T[]
  total: number
  size: number
  current: number
  pages: number
}

// 用户相关类型
export interface LoginParams {
  username: string
  password: string
}

// 登录响应数据
export interface UserInfo {
  id: number
  username: string
  nickname: string
  avatar?: string
  email?: string
  phone?: string
  status: string
  createTime: string
  updateTime: string
}

// 登录响应数据类型
export interface UserInfoResponse {
  user: UserInfo
  roles: string[]
  permissions: string[]
  menus: RouteMenu[]
}

// 菜单路由类型
export interface RouteMenu {
  id: number
  parentId: number
  title: string
  path: string
  component?: string
  type: number
  permission?: string
  icon?: string
  sort: number
  status: string
  children?: RouteMenu[]
}

// 角色类型
export interface Role {
  id: number
  name: string
  code: string
  status: string
  createTime?: string
  updateTime?: string
}

// 角色相关类型
export interface RoleDTO {
  id?: number
  name: string
  code: string
  sort: number
  status: string
  remark?: string
  menuIds?: number[]
}

// 角色查询参数
export interface RoleQuery extends PageParams {
  keyword?: string
  status?: string
}

// 菜单权限VO
export interface MenuPermissionVO {
  id: number
  title: string
  checked: boolean
  halfChecked: boolean
  children?: MenuPermissionVO[]
}

// 菜单类型
export interface Menu {
  id?: number
  parentId: number
  type: number
  title: string
  name: string
  path: string
  component?: string
  permission?: string
  icon?: string
  sort: number
  status: string
  children?: Menu[]
  meta?: {
    title: string
    icon?: string
  }
}

// 菜单提交参数类型
export interface MenuDTO {
  id?: number
  parentId: number
  type: number
  title: string
  name: string
  path: string
  component?: string
  permission?: string
  icon?: string
  sort: number
  status: string
  meta?: {
    title: string
    icon?: string
  }
} 